<h1>Alterar SIituação</h1>
<?php
echo $this->Form->create('Compra');
echo $this->Form->input('situacao_id', array("id" => "situacao", 'label' => 'Situação', 'options' => $situacoes, "class"=>"form-control", 'div' => array('class'=>'form-group')));
?>
<div id="rastreamento">
<?php
echo $this->Form->input('cd_rastreamento', array('label' => 'Código de Rastreamento', "class"=>"form-control", 'div' => array('class'=>'form-group')));
?>
</div>
<?php
echo $this->Form->end('Salvar');
?>
<script>
$("#situacao").on('change', function(e){
  var rast = document.querySelector("#rastreamento");
  if(this.value == 2){
    rast.style.display = "block";
  } else {
    rast.style.display = "none";
  }
});
$("#situacao").trigger('change');
</script>
